{template 'header'}
<ul class="nav nav-tabs">
	<li {if $_GPC['op']==''}class="active"{/if}><a href="{php echo $this->createWebUrl('listitem');}">订单列表</a></li>
</ul>
<style>
.table td span{display:inline-block;margin-top:4px;}
.table td input{margin-bottom:0;}
th{
	text-align: center !important;
}

.red{color:red;font-weight:bold}
</style>

<div class="main">
<div class="panel panel-info">
<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
        	<input type="hidden" name="m" value="bsht_tbk" />
        	<input type="hidden" name="do" value="listorderus" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
				<div class="col-sm-8 col-lg-2">
					<input class="form-control" name="keyword" id="" placeholder="输入商品名称或商品代码或订单号" type="text" value="{$_GPC['keyword']}">
				</div>

				
				
			</div>
			<div class="form-group">

                <label class="col-xs-2 col-sm-2 col-md-2 col-lg-1 control-label">分页显示量</label>
				<div class="col-sm-2 col-lg-1">
					<input class="form-control" name="psize" id="" placeholder="默认10个" type="text" value="{$_GPC['psize']}">
				</div>

				<div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-info"><i class="fa fa-search"></i> 搜 索</button>
				</div>
			</div>

 			<div class="form-group">
			</div>
		</form>
		
	</div>
</div>

<form action="" method="post" class="form-horizontal" role="form">
	<div style="padding:15px;background: white;">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
				    <th style="width:3em;">
                        <input type="checkbox" id="checkall"/>
                    </th>
					<th style="width:3em;">ID</th>
					<th style="width:170px;text-align:left">订单编号</th>
					<th style="width:170px">订单状态</th>
					<th style="width:100px">付款金额</th>
					<th style="width:100px">收入比例</th>
					<th style="width:100px">效果预估</th>
					<th style="width:auto;text-align:left">用户信息</th>
					
					<th style="width:auto">时间信息</th>

					
					
					<th style="width:90px;text-align:center">信息状态</th>
					<th style="width:auto;text-align:right">修改/删除</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
				    <td><input type="checkbox" name="ids[]" value="{$item['id']}" /></td>
					<td>{$item['id']}</td>
					<td style="width:auto;text-align:center"><label class="label label-success">{$item['orderid']}</label></td>
{if $item['queren']!=1}				
<td style="width:auto;text-align:center">
{if $item['oredrok']==1}
<span class="label label-{if $item['orderstatus2']=='订单结算'}success{/if}{if $item['orderstatus2']=='订单付款'}warning{/if}{if $row['orderstatus2']=='订单失效'}danger{/if}">{$item['orderstatus2']}</span>
{else}
<span class="label label-danger">单号无匹配</span>
{/if}
</td>
{else}
<td style="text-align:center"><span class="label label-warning">该晒单已被确认</span></td>
{/if}					
					
					</td>
					<td><label class="label label-info">￥{$item['orderfee2']}</label></td>
					<td><label class="label label-warning">{$item['shouru_bili2']}%</label></td>
					<td><label class="label label-danger">￥{$item['shouru_yongjin2']}</label></td>
					<td style="text-align:left"><label class="label label-info">{$item['openid']}</label><div style="height:10px"></div>{$item['nickname']}</td>
					<td style="text-align:center">
					<label class="label label-sm label-warning"">创建：{php echo date('Y-m-d H:i:s',$item['ctime'])}</label>
					</td>
                    
                    

					<td style="text-align:center" data-id='{$item["id"]}'>{if $item['status']}<label class="label label-success status">有效</label>{else}<label class="label label-default status">失效</label>{/if}</td>
{php $fltype=$setting['fltype']}
{if $fltype==1}{php $bili=$setting['ddbili'];}{else}{php $bili=$setting['ddbili']/100;}{/if}
					
					<td style="width:auto;text-align:right">  
                         {if $item['oredrok']==1}
                         {if $item['queren']==0}
						 <a class="btn btn-sm btn-info" href="javascript:importrow1({php echo $item['shouru_yongjin2']*$bili},{$item['id']})"><i class="fa fa-times"></i> 确认赠送 ({php echo $item['shouru_yongjin2']*$bili}{if $fltype==1}积分{else}余额{/if})</a>
						 {else}
						 <a class="btn btn-sm btn-success" href="javascript:">已确认</a>
						 {/if}
						 {else}
						 <a class="btn btn-sm btn-danger" href="javascript:">暂无匹配</a>
						 {/if}
						 <a class="btn btn-sm btn-danger" rel="tooltip" href="javascript:void();" onclick="drop_confirm('您确定要删除吗?删除不可恢复，同时删除所有相关数据！', '{php echo $this->createWebUrl('listorderus_del',array('id'=>$item['id'],'queren'=>$item['queren']))}');" title="删除并扣除{if $fltype==1}积分{else}余额{/if}">删除{if $item['queren']==1}并扣除{if $fltype==1}积分{else}余额{/if}({if $fltype==1}{$item['jifen']}{else}{$item['flfee']}{/if}){/if} <i class="fa fa-times"></i></a>
					</td>
				</tr>
				{/loop}

                <tr>
				    <th style="width:3em;">
                        <input type="checkbox" id="checkallbottom"/>
                    </th>
					
				</tr>

				<tr>
	                <td colspan="11" style="text-align: left !important;">
	                	<input name="token" type="hidden" value="{$_W['token']}" />

						<a data-href="{php echo $this->createWebUrl('listorderus',array('op'=>'delall'))}" href="javascript:;" class="btn btn-danger mutdelete">删除选中</a>
	                </td>
	            </tr>


			</tbody>
			
		</table>
		{$pager}
	</div>
</form>
</div>
<style>
	.masklayer{ display: none; width: 100%; height: 100%; position: fixed; z-index: 1000; top: 0px; left: 0px; background: rgba(0,0,0,0.7);}
	.mask{ display: none; width: 460px; height: auto; overflow: hidden; position: fixed; z-index: 2000; left: 50%; margin-left: -230px; background: #fff; top: 20%;}
	.mask .title{ width: 100%; height: 40px; line-height: 40px; background:#467ab3; position: relative; z-index: 10;}
	.mask .title span{ margin-left: 15px; color: #fff; font-size: 14px;}
	.mask .title .close{ width: 40px; height: 40px; position: absolute; display: block; top: 7px; right: -15px;color:#fff; z-index: 20;}
	.maskMain{  padding: 0px; height: auto; overflow: hidden; text-align: center; padding-bottom: 30px;}
	.maskMain a{ width: 40%; height: 46px; line-height: 46px; text-align: center; display: inline-block; background: #467ab3; color: #fff; border: 1px solid #000; margin: 30px 15px 0px 15px;}
</style>
<div class="masklayer" onclick="javascript:close1();" style="display: none;" id="masklayer1"></div>
<div class="mask maskOuter" style="display: none;" id="mask1">
			<p class="title">
				<span>请选择{if $fltype==1}积分{else}余额{/if}奖励方式</span>
				<em class="close" onclick="javascript:close1();">X</em>
			</p>
			<div class="maskMain">
				<input type="text" id="diyjifen" name="diyjifen" value="0"/>  额外奖励{if $fltype==1}积分{else}余额{/if}
				<input type="hidden" id="jifen" name="jifen" value="" />
				<input type="hidden" id="jfid" name="jfid" value="" />
				<button class="btn btn-info" style="margin-left:5%;margin-top:20px;" onclick="queren();">确认基础奖励{if $fltype==1}积分{else}余额{/if}，并额外奖励{if $fltype==1}积分{else}余额{/if}</button>
			</div>
</div>


<script>

function queren(){
	var jfid = $('#jfid').val();
	var diyjifen = $('#diyjifen').val();
	var jifen = $('#jifen').val();
	drop_confirm('确定奖励'+jifen+'{if $fltype==1}积分{else}余额{/if},以及额外奖励'+diyjifen+'{if $fltype==1}积分{else}余额{/if}？', './index.php?c=site&a=entry&id='+jfid+'&do=listorderus_jifen&m=bsht_tbk&diyjifen='+diyjifen+'&jifen='+jifen);
}


            function drop_confirm(msg, url){
            if (confirm(msg)){
            window.location = url;
            }
            }

function importrow1(jifen,jfid){
	$('#jfid').val(jfid);
	$('#jifen').val(jifen);
	$("#mask1").fadeIn(500);
	$("#masklayer1").fadeIn(500);
}

function close1(){
	$(".maskOuter").fadeOut(500);
	$(".masklayer").fadeOut(500);
}
</script>

<script>
require(['util'],function(util){
$('.mutdelete').click(function(){
            var url = $(this).data('href');
            var ids = [];
            var idss = [];
            $('input:checkbox[name="ids[]"]').each(function() {
                var _that = $(this)[0];
                if(_that.checked){
                    ids = ids.concat($(this).val());
                }else{
                    idss = idss.concat($(this).val());
                }
            });
            console.log(ids);
            if(confirm("您确定要删除么？")){
                $.post(url,{ids:ids},function(data){
                    util.message("删除成功","{php echo $_W['siteurl']}",'success');
                },'json');
            }
        });




$("#checkall").click(function(){
            console.log('checkall');
            $('input[name="ids[]"').each(function(){
                var _that = $(this)[0];
                if(_that.checked){
                    _that.checked = false;
                }else{
                    _that.checked = true;
                }
            });
        });


$("#checkallbottom").click(function(){
            $("#checkall").click();
        });


$('table .status').click(function(){
	var label = $(this);
	$.ajax({
		url:'{php echo $this->createWebUrl("listorderus",array("op"=>"status"))}',
		type:'post',
		data:{id:label.parent().attr('data-id')},
		success:function(status){
			if(status == '1'){
				if(label.hasClass('label-success')){
					label.removeClass('label-success').addClass('label-default');
					label.text('失效');
				}else{
					label.removeClass('label-default').addClass('label-success');
					label.text('有效');
				}
			}
		}
	});
  });
});
</script>

{template 'footer'}
